<?
$query = "SELECT * FROM payments WHERE reseller_id=$GLOBALS[id] AND status='paid' ORDER BY payment_id DESC";
$GLOBALS['master_db']->query($query);
$result = $GLOBALS['master_db']->getAll();

$params['sid'] = $sid;
$params['action'] = 'view_self_billing';

?>
<br />
<table class='bTable' cellspacing=0 cellpadding=0 width=100%>
	<tr>
		<td style="background:url(images/bkg_sbti_theader.gif) top repeat-x;" colspan="4" align="center"><strong>SELF-BILLING TaX INVOICES</strong></td>
	</tr>
<?
if($result){
	$pm = array('wire'=>'Bank Wire','paypal'=>'PayPal','wallet'=>'Wallet','check'=>'Check');
	echo "<tr>
		<th>Invoice#</th>
		<th>Amount</th>
		<th>Payment Method</th>
		<th>Date</th>
	</tr>";
	foreach($result as $k => $v){
		if($v['payment_method'] == 'paypal'){
			$payment_info = $pm[($v['payment_method'])].' #'.$v['paypal_transaction_id'];
		}elseif($v['check']){
			$payment_info = $pm[($v['payment_method'])].' #'.$v['check_number'];
		}else{
			$payment_info = $pm[($v['payment_method'])];
		}

		$params['payment_id'] = $v[payment_id];
		$view_url = $GLOBALS['baseURL'].'/?'.encode_params($params);

		echo "<tr>
			<td align='center'><img src='images/ico_coins_sbti.gif' width='10' height='10'> <a href='$view_url' target='_blank'>$v[payment_id]</a></td>
			<td align='right' style='padding-right:20px;'>US$ ".number_format($v['amount'], 2, ',', ' ')."</td>
			<td align='center'>$payment_info</td>
			<td align='right' style='padding-right:20px;'>".date('m/d/Y', strtotime($v['change_status_date']))."</td>
		</tr>";
	}
	echo '</table><br>';
}else{
	echo '<tr>
		<td align="center" colspan=3><font color="red"><strong>YOU DON\'T HAVE ANY COMMISSIONS YET!</strong></font></td>
	</tr>';
}
?>